import { QXEvent } from "qx-util";
import { IParam, KanBanActionType, IKanBanAbility, IKanBanControllerParams, IKanBanStore, KanBanController, ICtrlEvent, IKanBanController, IKanBanModel } from "@/core";
import { useKanBanAction, useKanBanBasic, useKanBanControllerParams, useKanBanProps } from "@/hooks/widget/use-kanban";
import { KanbanControlVO } from './has-panel-kan-ban-kanban-vo';
import { model } from "./has-panel-kan-ban-kanban-model";
import KanBanService from "@/core/modules/ctrl-service/kanban-service";
// 基于template/src/widgets/{{appEntities}}/{{ctrls@KANBAN}}-kanban/{{spinalCase ctrl.codeName}}-kanban-hook.ts.hbs生成
/**
 * 获取输入参数
 *
 * @export
 * @return {*}
 */
export function useProps() {
	return {
		...useKanBanProps(),
	};
}

/**
 * 获取基础数据
 *
 * @export
 * @param {*} props
 * @return {*}
 */
export function useBasic(props: any) {
	return {
		...useKanBanBasic(model, props),
	};
}

/**
 * 获取行为
 *
 * @export
 */
export function useAction(controller: any) {
	return {
		...useKanBanAction(controller),
	};
}

/**
 * 获取控制器
 *
 * @export
 * @param {IParam} props
 * @param {QXEvent<ICtrlEvent<KanBanActionType, IKanBanAbility>>} evt
 * @return {*}
 */
export function useController(
	props: IParam,
	evt: QXEvent<ICtrlEvent<KanBanActionType, IKanBanAbility>>,
    otherParams: IParam = {},
): IKanBanController<IKanBanStore, IKanBanAbility> {
	const params: IKanBanControllerParams<KanBanActionType, IKanBanAbility> =
		useKanBanControllerParams<IKanBanStore, IKanBanModel>(model, props, evt, otherParams);
    const ctrlService = new KanBanService<KanbanControlVO>(KanbanControlVO, model.entityCodeName, { model });
  	Object.assign(params, { ctrlService });
  	return new KanBanController(params);
}